<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of stmailer
 *
 * @author phamhphuc
 */
class stmailer {
    //put your code here
    public function _sendAWSEmail($data) {        
        $data['token'] = "8asd6f8a7ds6fa6a8sdf";
        $apiURL = "http://test.slopetracker.no/phuc/sesservice/service.php?rnd=" . time();                
        $ch = curl_init ($apiURL);
        curl_setopt ($ch, CURLOPT_POST, true);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
        $returndata = curl_exec ($ch);
        return $returndata;
    }
    
    public function _sendPHPMail($maildata) {
//        $maildata = array(
//                        'to'  => 'knut@spanord.com',
//                        'bcc' => 'mick@slopetracker.no',
//                        'toname' => 'Knut',
//                        'from' => 'Knut H Nordbotn<knutnord@online.no>',
//                        'subject' => 'Kontakt oss',
//                        'message' => $mailcontent
//                    );
        // multiple recipients
//        $to  = 'aidan@example.com' . ', '; // note the comma
        $to = "{$maildata['toname']}<{$maildata['to']}>";
        // subject
        $subject = $maildata['subject'];

        // message
        $message = $maildata['message'];

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

        // Additional headers
        $headers .= "To: {$to}" . "\r\n";
        $headers .= "From: {$maildata['from']}" . "\r\n";        
        $headers .= "Bcc: {$maildata['bcc']}" . "\r\n";

        // Mail it
        mail($to, $subject, $message, $headers);
    }
}

?>
